package main.java.design.iterator;

/**
 * <p>
 *     迭代器模式
 * </p>
 *
 * @author : wangdejian
 * @version 1.0
 * @date : 2020/6/21 17:48
 */
public class Client {

    public static void main(String[] args) {

        ConcreateAggregate<String> aggregate = new ConcreateAggregate<>();
        aggregate.add("a");
        aggregate.add("v");
        aggregate.add("s");
        aggregate.add("d");

        Iterator<String> iterator = aggregate.createIterator();
        System.out.println("第一个是：" + iterator.first());
        System.out.println("最后一个是：" + iterator.last());
        System.out.println("当前的元素是: " + iterator.currentItem());
        while (iterator.hasNext()) {

            System.out.println("下一个是：" + iterator.next());
        }


    }
}
